package com.zzl.admin.entity.admin;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzl.admin.entity.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Table;
import javax.persistence.*;
import java.util.Date;

/**
 * Description：资源实体类
 * Created by 朱正磊 on 2019-03-22 0:54
 */
@Entity(name = "tb_resource")
@Data
@EqualsAndHashCode(callSuper = false)
@Table(appliesTo = "tb_resource", comment = "资源表")
public class Resource extends BaseEntity {

    private static final long serialVersionUID = -2481049256419136780L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(columnDefinition = "int(11) comment '资源id'")
    private Integer id;

    @Column(columnDefinition = "varchar(255) comment '资源名称'")
    private String name;

    @Column(columnDefinition = "varchar(255) comment '资源唯一标识'")
    private String sourceKey;

    @Column(columnDefinition = "int(11) comment '资源类型：0-目录；1-菜单；2-按钮'")
    private Integer type;

    @Column(columnDefinition = "varchar(255) comment '资源url'")
    private String sourceUrl;

    @Column(columnDefinition = "int(11) comment '层级'")
    private Integer level;

    @Column(columnDefinition = "int(11) comment '排序'")
    private Integer sort;

    @Column(columnDefinition = "varchar(255) comment '图标'")
    private String icon;

    @Column(columnDefinition = "int(11) comment '是否隐藏：0-显示；1-隐藏'")
    private Integer isHide;

    @Column(columnDefinition = "varchar(255) comment '描述'")
    private String description;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(columnDefinition = "datetime comment '创建时间'")
    private Date createTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(columnDefinition = "datetime comment '更新时间'")
    private Date updateTime;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id")
    private Resource parent;

}
